package com.coodean.mybatis.demo.dao;

import com.coodean.mybatis.demo.entity.Author;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * Created by weichengke on 6/25/17.
 */
public interface AuthorDao {

    @Insert("insert into author (username, password,email,bio) values(#{username}, #{password}, #{email}, #{bio})")
    int insert(Author author);


    @Select("select * from author where id = #{id}")
    Author selectById(Long id);

    @Update("update author set" +
            "        username = #{username}," +
            "        password = #{password}," +
            "        email = #{email}," +
            "        bio = #{bio}" +
            "        where id = #{id}")
    int update(Author author);

    @Delete("delete from author where id=#{id}")
    int delete(Long id);
}
